<!-- 购物卡结佣管理-购物卡查询-->
<template>
    <div class="shoppingCardQuery">
        <el-form :inline="true" :model="searchParams">
            <el-form-item label="楼盘名称:">
                <el-select
                        v-model="searchParams.devName"
                        placeholder="请输入楼盘名称"
                        filterable
                >
                    <el-option v-for="(item,index) in allEstateList" :key="index" :label="item.devName" :value="item.devName"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSearch" id="monitorEnter">查询</el-button>
                <el-button @click="onClear">重置</el-button>
            </el-form-item>
        </el-form>
        <el-table :data="tableData" border style="width: 100%">
            <el-table-column align="center" type="index" label="序号" width="50"></el-table-column>
            <el-table-column align="center" prop="projectName" label="项目"></el-table-column>
            <el-table-column align="center" prop="devName" label="楼盘"></el-table-column>
            <el-table-column align="center" prop="shouldPayCardAmount" label="应支付购物卡(元)">
                <template slot-scope="scope">{{scope.row.shouldPayCardAmount | formatMoney}}</template>
            </el-table-column>
            <el-table-column align="center" prop="storeCardAmount" label="购物卡库存(元)">
                <template slot-scope="scope">
                    <a class="handleA" href="javascript:" @click="goOtherPage('stock', scope.row)">{{scope.row.storeCardAmount
                        | formatMoney}}</a>
                </template>
            </el-table-column>
            <el-table-column align="center" prop="waitBuyCardAmount" label="购物卡待采购(元)">
                <template slot-scope="scope">{{scope.row.waitBuyCardAmount | formatMoney}}</template>
            </el-table-column>
            <el-table-column align="center" prop="alreadyBuyCardAmount" label="购物卡已采购(元)">
                <template slot-scope="scope">{{scope.row.alreadyBuyCardAmount | formatMoney}}</template>
            </el-table-column>
            <el-table-column align="center" prop="alreadyGiveOutCardAmount" label="购物卡已发放(元)">
                <template slot-scope="scope">
                    <a class="handleA" href="javascript:" @click="goOtherPage('send', scope.row)">{{scope.row.alreadyGiveOutCardAmount
                        |
                        formatMoney}}</a></template>
            </el-table-column>
        </el-table>
        <div class="pagebar">
            <el-pagination
                    background
                    layout="total, sizes, prev, pager, next"
                    :current-page.sync="tableConfig.pageNum"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="tableConfig.pageSize"
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :total="tableConfig.totalSize">
            </el-pagination>
        </div>

    </div>
</template>

<script type="text/ecmascript-6">
    import api from '@/api/apiPath'
    import utils from "@/common/utils.js";

    export default {
        name: 'shoppingCardQuery',
        title:'购物卡查询',
        data() {
            return {
                searchParams: {
                    devName: '',
                },
                tableConfig: {
                    pageSize: 10,
                    pageNum: 1,
                    totalSize: 10
                },
                allEstateList: [],
                tableData: []
            }
        },
        created() {
            this.queryAllEstate();
            this.getTableList();
        },
        activated(){
            this.onSearch()
        },
        mounted() {

        },
        methods: {
            onSearch() {
                this.tableConfig.pageNum = 1;
                this.getTableList();
            },
            onClear() {
                this.searchParams = {
                    devName: '',
                }
            },
            getTableList() {
                this.axios.post(api.couponShoppingCardQuery, {
                    devName: this.searchParams.devName,
                    pageNum: this.tableConfig.pageNum,
                    pageSize: this.tableConfig.pageSize,
                }).then((res) => {
                    this.tableData = res.data.data.list;
                    this.tableConfig.totalSize = res.data.data.total;
                })
            },
            handleSizeChange(size) {
                this.tableConfig.pageSize = size
                this.getTableList()
            },
            handleCurrentChange(page) {
                this.tableConfig.pageNum = page
                this.getTableList()
            },
            queryAllEstate() {
                this.axios.post(api.queryAllEstateShoppingCardUse, {}).then((res) => {
                    this.allEstateList = res.data.data
                })
            },
            goOtherPage(type, row) {
                let query = {devId: row.devId + ""}
                if (type === 'send') {
                    query.giveOutFlag = "1"
                }
                this.$router.push({
                    path: "./shoppingCardStock",
                    query: query
                })
            }
        },
        filters: {
            formatMoney(money) {
                return utils.formatMoney(money)
            }
        },
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="stylus" scoped>
    .handleA {
        text-decoration: none;
    }
</style>
